<!--入职申请表-->


<?php include('header.php') ?>

<div id="mainbody"  >
<div class="col-lg-9" id="charge">
    <table class="table table-bordered" id="work-table">
      <tr id="table-nav">
        <td> 学号</td>
        <td> 姓名</td>
		<td>性别</td>
        <td> 学院</td>
        <td>专业</td>
      </tr>
  		<?php

function table($tabname){
// 	$sql="select * from $tabname";
	$sql = " drop table if exists tmp_info";
	mysql_query($sql);
	$sql1 = "create table tmp_info (id char(11), name varchar(25), sex varchar(3), college varchar(33), major varchar(54)) default charset = utf8";
	$sql2 = "insert into tmp_info select allstudent.studentid, allstudent.studentname, allstudent.sex ,allstudent.college, allstudent.major from allstudent , apply where allstudent.studentid = apply.studentid and apply.checked='no'";
	mysql_query($sql1);
	mysql_query($sql2);
	$sql3 = "select * from tmp_info";
	$result=mysql_query($sql3);
	if ($result==null){
		echo "结果为空!";
	}
	
	$url="apply_list.php";
	//每页显示的记录条数
	$num=10;
	//sql结果集记录总条数
	$total=mysql_num_rows($result);
	//ceil()函数,向上取整. 总页码
	$pagenum=ceil($total/$num);
	//确定当前页码.
	$cpage=isset($_GET["page"])?$_GET["page"]:1;
	//limit偏移量
	$offset=($cpage-1)*$num;
	$sql="select * from tmp_info limit {$offset},{$num}";
	$result=mysql_query($sql);
	//当前页起始记录
	$start=$offset+1;
	//当前页最后一条记录
	$end=($cpage==$pagenum)?$total:($cpage*$num);
	//上一页
	$prev=($cpage==1)?0:($cpage-1);
	//下一页
	$next=($cpage==$pagenum)?0:($cpage+1);
		
	$rows=mysql_num_rows($result);
	$cols=mysql_num_fields($result);
	//输出值
	while($row=mysql_fetch_array($result)){
		echo '<tr >';
		echo '<td>'."<a title = '查看详细信息' href='apply_info.php?id=".$row["id"]."'>".$row["id"]."</a>".'</td>';
		echo  '<td>'.$row["name"] .'</td>';
		echo  '<td>'.$row["sex"] .'</td>';
		echo  '<td>'.$row["college"] .'</td>';
		echo  '<td>'.$row["major"] .'</td>';
		echo '</tr>';
	}
	echo '<tr align="center"><td colspan="'.$cols.'">';
	echo "共：{$total}条记录，当前显示：{$start}-{$end}，当前页面：{$cpage}/{$pagenum}";
	//判断"首页"按钮是否可用.
	if($cpage==1)
		echo "&nbsp;&nbsp;首页&nbsp;&nbsp;";
	else
		echo "&nbsp;&nbsp;<a href='{$url}?page=1'>首页</a>&nbsp;&nbsp;";
	//判断上一页是否可用
	if($prev)
		echo "&nbsp;&nbsp;<a href='{$url}?page={$prev}'>上一页</a>&nbsp;&nbsp;";
	else
		echo "&nbsp;&nbsp;上一页&nbsp;&nbsp;";
	//判断下一页是否可用
	if($next)
		echo "&nbsp;&nbsp;<a href='{$url}?page={$next}'>下一页</a>&nbsp;&nbsp;";
	else
		echo "&nbsp;&nbsp;下一页&nbsp;&nbsp;";
	//判断"尾页"按钮是否可用
	if($cpage==$pagenum)
		echo "&nbsp;&nbsp;尾页&nbsp;&nbsp;";
	else
		echo "&nbsp;&nbsp;<a href='{$url}?page={$pagenum}'>尾页</a>&nbsp;&nbsp;";
	echo '</tr></td>';
	echo '</table>';
	mysql_free_result($result);
	mysql_close();
}
table("apply_table");
?> 
   </table>



<?php include('foot.php') ?>